#include<iostream>
using namespace std;

typedef struct LNode
{	
	char ch;
	struct LNode *next;
}tLNode;

tLNode *head;

void addNode(char c);

void 
createList(char s[],int len)
{
	head = new tLNode();
	head->next = NULL;
	for(int i=0;i<len;i++)
	{
		addNode(s[i]);
	}
}

void 
addNode(char c)
{
	tLNode *p = head;
	while(p->next!=NULL)
		p = p->next;
	tLNode *s = new tLNode();
	s->ch = c;
	s->next = NULL;
	p->next = s;
}

void deleteNode(char c)
{
	tLNode *p = head;
	tLNode *q ;
	while(p->next!=NULL)
	{
		q = p;
		p=p->next;
		if(p->ch == c)
		{
			q->next = p->next;
			delete(p);
			break;
		}
	}
	return ;
}

void 
display()
{
	tLNode *p = head;
	while(p->next!=NULL)
	{
		p=p->next;
		cout<<p->ch<<" ";
	}
	cout<<endl;
}


int main()
{
	char s[]={'a','b','c','d','e'};
	int len = sizeof(s)/sizeof(s[0]);
	createList(s,len);
	display();
	deleteNode(s[2]);
	display();
	return 0;
}
